package com.sms.msger.conf;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ConfigManager {
	private static final Log logger = LogFactory.getLog(Configs.class);

	public HashMap<String, String> hashmap = new HashMap<String, String>();

	public ConfigManager() {
	}

	public void load(String configFileName) {
		hashmap.clear();
		try {
			BufferedInputStream buffer = new BufferedInputStream(
					new FileInputStream(configFileName));
			Properties props = new Properties();
			props.load(buffer);
			Enumeration enumeration = props.propertyNames();
			while (enumeration.hasMoreElements()) {
				String key = (String) enumeration.nextElement();
				String value = props.getProperty(key);
				hashmap.put(key, value);
			}
			buffer.close();
		} catch (Exception e) {
			e.printStackTrace();
			if (logger.isErrorEnabled())
				logger.error(e.getMessage(),e);
		}

	}

}
